<!-- 功能：报警日志 | 作者：menghao.yan | 邮箱：yxs2615@163.com | 时间：2023年08月22日 23:04:35 -->
<template>
  <a-tabs v-model:activeKey="activeKey" type="card" class="y-tabs">
    <a-tab-pane :key="'kongzhiqi_'+ index" :tab="'控制器-'+index" v-for="index in 3">
      <a-row>
        <a-col :span="24">
          <a-space>
            <a-button type="link" class="y-btn" @click="">
              <template #icon>
                <sync-outlined />
              </template>
              刷新日志
            </a-button>
            <a-button type="link" class="y-btn" @click="">
              <template #icon>
               <EyeOutlined />
              </template>
              查看保存的日志
            </a-button>
            <a-button type="link" class="y-btn" @click="baoCunDangQianRiZhi">
              <template #icon>
                <SaveOutlined />
              </template>
              保存当前日志
            </a-button>
          </a-space>
        </a-col>
      </a-row>

      <a-card>
        <a-row align="middle">
          <a-col :span="16">
            <a-space>
            </a-space>
          </a-col>
          <a-col :span="8">
            <a-input v-model:value="searchValue">
              <template #addonBefore>
                <search-outlined /> 搜索:
              </template>
            </a-input>
          </a-col>
        </a-row>
        <a-table bordered :data-source="dataSource" :columns="columns" class="y-table" :pagination="pagination">
        </a-table>
      </a-card>
    </a-tab-pane>
  </a-tabs>
</template>

<script setup>
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
import { Modal } from 'ant-design-vue'
const visibleXinZengJingTaiLuYouModal = ref(false)

const searchValue = ref('')

const openXinZengJingTaiLuYouModal = () => {
  visibleXinZengJingTaiLuYouModal.value = true
}

const activeKey = ref('kongzhiqi_1')

// 表格列
const columns = ref([
  {
    title: '时间',
    dataIndex: 'time',
    key: 'time',
    align: 'center',
    sorter: {
      compare: (a, b) => a.time.localeCompare(b.time),
      multiple: 1
    }
  },
  {
    title: '状态',
    dataIndex: 'zhuangTai',
    key: 'zhuangTai',
    align: 'center',
    sorter: {
      compare: (a, b) => a.zhuangTai.localeCompare(b.zhuangTai),
      multiple: 2
    }
  },
  {
    title: '事件',
    dataIndex: 'shiJian',
    key: 'shiJian',
    align: 'center',
    sorter: {
      compare: (a, b) => a.shiJian.localeCompare(b.shiJian),
      multiple: 3
    }
  }
])

// 表格数据
const dataSource = ref([
  {
    key: '1',
    time: '2021-04-12 15:12:22',
    zhuangTai: '成功',
    shiJian: 'controller-1 重启成功'
  },
  {
    key: '2',
    time: '2021-04-12 15:12:22',
    zhuangTai: '成功',
    shiJian: 'controller-1 重启成功'
  }
])

// 分页
const pagination = {
  current: 1,
  pageSize: 10,
  showQuickJumper: true,
  showSizeChanger: true,
  total: 0,
  showTotal: (total, range) => {
    return `${range[0]}-${range[1]} 共 ${total} 条数据`
  },
  onChange: (page, pageSize) => {
    console.log('报警日志>>', page, pageSize)
  }
}

// 保存当前日志
const baoCunDangQianRiZhi = () => {
  Modal.confirm({
    title: '确认操作',
    icon: h(ExclamationCircleOutlined),
    content: '您确定要保存(备份)并删除当前日志文件?',
    okText: '确定',
    okType: 'danger',
    cancelText: '取消',
    onOk() {
      console.log('OK')
    },
    onCancel() {
      console.log('Cancel')
    }
  })
}
</script>

<style scoped lang='scss'>
.ant-row {
  margin-bottom: 10px;
}
</style>